#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int l, m,v,u;
	int flag = 0;
	int a[10000];
	scanf("%d%d", &l, &m);
	for (int i = 0; i <= l; i++)
		a[i] = 1;
	for (int n = 0; n < m; n++)
	{
		scanf("%d%d", &u, &v);
		for (int i = u; i <= v; i++)
		{
			a[i] = 0;
		}
	}
	for (int i = 0; i <= l; i++)
	{
		if (a[i] == 1)
			flag++;
	}
	printf("%d", flag);
	return 0;
}